home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
misc
/
emu
/
ATUtilities.lha
/
ATUtilities
/
M2
/
DOS.MOD
< prev
next >
Wrap
Text File
|
2000-09-26
|
2KB
|
78 lines
IMPLEMENTATION MODULE DOS;
FROM SYSTEM IMPORT ADDRESS,ADR,OFS,SEG;
FROM System IMPORT FLAGS,ES,DS,SI,DI,AX,BX,CX,DX,Trap,XTrap,carryFlag;
FROM Storage IMPORT ALLOCATE,DEALLOCATE;
FROM Files IMPORT CreateTemp,Read,Write,Seek,Close,Delete,FileStatus,SeekMode;
FROM GEM IMPORT gdos;
TYPE
PROCEDURE OpenTemporaryFile() : FileHandlePtr;
VAR fh : FileHandlePtr;
num,i : CARDINAL;
BEGIN
num := 0FFFFH;
FOR i := 0 TO 99 DO
IF (gdos^.tempFile[i]=NIL) THEN
num := i;
i := 100;
END (* IF *);
END (* FOR *);
IF (num=0FFFFH) THEN RETURN(NIL); END;
ALLOCATE(fh,SIZE(FileHandle));
IF (fh=NIL) THEN
RETURN(NIL);
END (* IF *);
fh^.name := "";
CreateTemp(fh^.handle,fh^.name,{});
IF (FileStatus<>0) THEN
DEALLOCATE(fh,SIZE(FileHandle));
RETURN(NIL);
END (* IF *);
fh^.tempNum := num;
gdos^.tempFile[num] := fh;
RETURN(fh);
END OpenTemporaryFile;
PROCEDURE CloseTemporaryFile(file : FileHandlePtr);
BEGIN
Close(file^.handle);
gdos^.tempFile[file^.tempNum] := NIL;
Delete(file^.name);
DEALLOCATE(file,SIZE(FileHandle));
END CloseTemporaryFile;
PROCEDURE WriteFile(file : FileHandlePtr;
data : ADDRESS;
len : CARDINAL) : CARDINAL;
VAR nwrite : CARDINAL;
BEGIN
Write(file^.handle,data,len,nwrite);
RETURN(nwrite);
END WriteFile;
PROCEDURE ReadFile(file : FileHandlePtr;
data : ADDRESS;
len : CARDINAL) : CARDINAL;
VAR nread : CARDINAL;
BEGIN
Read(file^.handle,data,len,nread);
RETURN(nread);
END ReadFile;
PROCEDURE SeekFile(file : FileHandlePtr;
pos : LONGCARD;
mode : CARDINAL);
VAR sm : SeekMode;
BEGIN
IF mode=offsetBeginning THEN sm := SEEKABS; END;
IF mode=offsetCurrent THEN sm := SEEKCUR; END;
IF mode=offsetEnd THEN sm := SEEKEND; END;
Seek(file^.handle,sm,pos);
END SeekFile;
END DOS.